package com.xiaochang.em.controller;

import com.xiaochang.em.common.Result;
import com.xiaochang.em.entity.Star;
import com.xiaochang.em.service.StarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/star")
public class StarController {

    @Resource
    private StarService starService;

    @GetMapping
    public Result findAll() {

        return Result.success(starService.allStar());
    }

    @GetMapping("/{obSid}")
    public Result getStar(@PathVariable String obSid) {
        return Result.success(starService.queryById(obSid));
    }

    @GetMapping("/page")
    public Result findPage(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") Integer pageSize ) {

        return Result.success(starService.queryAllStar(pageNum, pageSize));
    }

    @GetMapping("/classPage/{subClass}")
    public Result findClassPage(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(required = false, defaultValue = "") String subClass ){

        return Result.success(starService.queryClassStar(pageNum,pageSize,subClass));
    }

}
